<?xml version="1.0" encoding="utf-8"?>
<openerp>
	<data> 

	   <record id="view_tracking_journal_entries" model="ir.ui.view">
            <field name="name">tracking.journal.entries.form</field>
            <field name="model">tracking.journal.entries</field>
            <field name="arch" type="xml">
                <form string="Account Entry" create="0" edit="0" delete="false">
	            	<header>
	                    <button name="button_validate" states="draft" string="Post" type="object" class="oe_highlight" groups="account.group_account_invoice"/>
	                    <button name="button_cancel" states="posted" string="Cancel Entry" type="object" groups="account.group_account_invoice"/>
	                    <field name="state" widget="statusbar"/>
	                </header>
                    <label for="name" class="oe_edit_only" attrs="{'invisible':[('name','=','/')]}"/>
                    <h1>
                        <field name="name" readonly="True" attrs="{'invisible':[('name','=','/')]}"/>
                    </h1>
                    <group>
                        <group>
                            <field name="journal_id" readonly="1"/>
                            <field name="period_id" readonly="1"/>
                            <field name="company_id" readonly="1"/>
                            <field name="partner_id" invisible="1"/>
                        </group>
                        <group>
                            <field name="ref" readonly="1"/>
                            <field name="date" readonly="1"/>
                            <field name="to_check" readonly="1"/>
                            <field name="amount" invisible="1"/>
                        </group>
                    </group>
                    <notebook>
                        <page string="Journal Items">
                        	<field name="state" invisible='1'/>
                            <field name="line_id" widget="one2many_list"
                              context="{'line_id': line_id , 'journal_id': journal_id }">
                                <form string="Journal Item">
                                    <group col="6" colspan="4">
                                        <field name="name"/>
                                        <field name="ref"/>
                                        <field name="partner_id"
                                            domain="['|', ('parent_id', '=', False), ('is_company', '=', True)]"
                                            on_change="onchange_partner_id(False, partner_id, account_id, debit, credit, date, journal_id, context)"/>

                                        <field name="journal_id"/>
                                        <field name="period_id"/>
                                        <field name="company_id" required="1" groups="base.group_multi_company"/>
                                    </group>
                                    <notebook colspan="4">
                                        <page string="Information">
                                            <group>
                                                <group string="Amount">
                                                    <field name="account_id" domain="[('company_id', '=', parent.company_id), ('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
                                                    <field name="debit"/>
                                                    <field name="credit"/>
                                                    <field name="quantity"/>
                                                </group>

                                                <group string="Accounting Documents">
                                                    <field name="invoice"/>
                                                    <field name="move_id" required="False"/>
                                                    <field name="statement_id"/>
                                                </group>

                                                <group string="Dates">
                                                    <field name="date"/>
                                                    <field name="date_maturity"/>
                                                    <field name="date_created"/>
                                                </group>

                                                <group string="Taxes">
                                                    <field name="tax_code_id"/>
                                                    <field name="tax_amount"/>
                                                    <field name="account_tax_id" domain="[('parent_id','=',False)]"/>
                                                </group>

                                                <group string="Currency" groups="base.group_multi_currency">
                                                    <field name="currency_id"/>
                                                    <field name="amount_currency"/>
                                                </group>

                                                <group string="Reconciliation">
                                                    <field name="reconcile_id"/>
                                                    <field name="reconcile_partial_id"/>
                                                </group>

                                                <group string="States">
                                                    <field name="state"/>
                                                    <field name="blocked"/>
                                                </group>

                                                <group groups="analytic.group_analytic_accounting" string="Analytic">
                                                    <field name="analytic_account_id"/>
                                                </group>
                                            </group>
                                            <separator string="Internal Note"/>
                                            <field name="narration"/>
                                        </page>
                                        <page string="Analytic Lines" groups="analytic.group_analytic_accounting">
                                            <field colspan="4" name="analytic_lines" nolabel="1" context="{'default_general_account_id':account_id, 'default_name': name, 'default_date':date, 'amount': (debit or 0.0)-(credit or 0.0)}"/>
                                        </page>
                                    </notebook>
                               </form>
                               <tree colors="blue:state == 'draft';black:state == 'posted'" string="Journal Items">
                                    <field name="invoice"/>
                                    <field name="name"/>
                                    <field name="partner_id"
                                        domain="['|', ('parent_id', '=', False), ('is_company', '=', True)]"
                                        on_change="onchange_partner_id(False, partner_id, account_id, debit, credit, parent.date, parent.journal_id, context)"/>
                                    <field name="account_id" domain="[('journal_id','=',parent.journal_id),('company_id', '=', parent.company_id)]"/>
                                    <field name="date_maturity"/>
                                    <field name="debit" sum="Total Debit"/>
                                    <field name="credit" sum="Total Credit"/>
                                    <field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
                                    <field name="amount_currency"/>
                                    <field name="currency_id" groups="base.group_multi_currency"/>
                                    <field name="tax_code_id"/>
                                    <field name="tax_amount"/>
                                    <field name="state"/>
                                    <field name="reconcile_id"/>
                                    <field name="reconcile_partial_id"/>
                                </tree> 
                            </field>
                            <field name="narration" colspan="4" placeholder="Add an internal note..." nolabel="1" height="50"/>
                        </page>
                    </notebook>
                </form>
            </field>
       </record>

	   <record id="view_tracking_journal_entries_filter" model="ir.ui.view">
            <field name="name">tracking.journal.entries.filter</field>
            <field name="model">tracking.journal.entries</field>
            <field name="arch" type="xml">
                <search string="Search Move">
                    <field name="name" filter_domain="['|', ('name','ilike',self), ('ref','ilike',self)]" string="Move"/>
                    <field name="date"/>
                    <filter icon="terp-document-new" string="Unposted" domain="[('state','=','draft')]" help="Unposted Journal Entries"/>
                    <filter icon="terp-camera_test" string="Posted" domain="[('state','=','posted')]" help="Posted Journal Entries"/>
                    <separator/>
                    <filter icon="terp-gtk-jump-to-ltr" string="To Review" domain="[('to_check','=',True)]" help="Journal Entries to Review"/>
                    <field name="partner_id"/>
                    <field name="journal_id"/>
                    <field name="period_id"/>
                    <group expand="0" string="Group By">
                        <filter string="Partner" icon="terp-partner" domain="[]" context="{'group_by':'partner_id'}"/>
                        <filter string="Journal" icon="terp-folder-orange" domain="[]" context="{'group_by':'journal_id'}"/>
                        <filter string="States" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>
                        <filter string="Period" icon="terp-go-month" domain="[]" context="{'group_by':'period_id'}"/>
                        <filter string="Entries Month" icon="terp-go-month" domain="[]" context="{'group_by':'date'}" help="Journal Entries by Month"/>
                    </group>
                </search>
            </field>
       </record>
 	   
 	   <record id="view_tracking_journal_entries_tree" model="ir.ui.view">
            <field name="name">view.tracking.journal.entries.tree</field>
            <field name="model">tracking.journal.entries</field>
            <field name="arch" type="xml">
                <tree colors="blue:state == 'draft';black:state == 'posted'" string="Journal Entries" create="0" edit="0" delete="false">
                    <field name="name"/>
                    <field name="ref"/>
                    <field name="date"/>
                    <field name="period_id"/>
                    <field name="journal_id"/>
                    <field name="partner_id"/>
                    <field name="amount" sum="Total Amount"/>
                    <field name="state"/>
                </tree>
            </field>
       </record>
		
	   <record id="view_tracking_journal_entries_action" model="ir.actions.act_window">
            <field name="name">Journal Entries</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">tracking.journal.entries</field>
            <field name="view_mode">tree,form</field>
            <field name="view_id" ref="view_tracking_journal_entries_tree"/>
            <field name="search_view_id" ref="view_tracking_journal_entries_filter"/>
            <field name="help" type="html">
              <p class="oe_view_nocontent_create">
                Click to view or search journal entries.
              </p>
            </field>
       </record>
	   
	   <menuitem
            icon="STOCK_JUSTIFY_FILL"
            action="view_tracking_journal_entries_action"
            id="menu_tracking_journal_entries"
            parent="account.menu_finance_entries"
            sequence="6"/>
	</data>
</openerp>
